package com.zjmzxfzhl.modules.purchase.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zjmzxfzhl.common.base.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.sql.Date;

/**
 * 【】实体类
 *
 * @author 庄金明
 */
@Getter
@Setter
@TableName("T_PURCHASE_ORDER")
public class PurchaseOrder extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 采购单编号
     */
    @NotNull
    @Length(max = 20)
    private String orderCode;

    /**
     * 采购单名称
     */
    @NotNull
    @Length(max = 128)
    private String orderName;

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date orderDate;
    /**
     * 总价
     */
    @DecimalMax("999999999.99")
    private BigDecimal price;

    /**
     * 采购用途
     */
    @Length(max = 128)
    private String orderUsage;

    /**
     * 备注
     */
    @Length(max = 256)
    private String comment;

    /**
     * 状态 : 创建，领导审批已通过，
     */
    @Length(max = 128)
    private String orderState;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof PurchaseOrder)) {
            return false;
        }
        PurchaseOrder model2 = (PurchaseOrder) o;
        if (null != this.orderCode && this.orderCode.equals(model2.getOrderCode())) {
            return true;
        } else {
            return false;
        }

    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + orderCode.hashCode();
        return result;
    }


}
